# Maintainer: LoveSy <shana@zju.edu.cn>

pkgname="openbsd-netcat"
pkgver=1.190
pkgrel=2
pkgdesc="TCP/IP swiss army knife. OpenBSD variant."
arch=('i686' 'x86_64')
url="https://packages.debian.org/sid/netcat-openbsd"
license=('BSD')
provides=('netcat')
conflicts=('gnu-netcat')
source=("http://ftp.debian.org/debian/pool/main/n/netcat-openbsd/netcat-openbsd_${pkgver}.orig.tar.gz"
	"http://ftp.debian.org/debian/pool/main/n/netcat-openbsd/netcat-openbsd_${pkgver}-${pkgrel}.debian.tar.xz"
    'openbsd-netcat.patch')
sha256sums=('68ccc448392c05ec51baed0167a72b8c650454f990b895d6e6877d416a38e536'
            '88088af3f520c7825e59bc133d65e70fc4a30139d451c6faabbd9f240bc78374'
            'a55a35b0dc3a600324295235a7eea5dc5abada6e5506ba318087abd6c0c7766c')

prepare() {
  cd "$srcdir"/netcat-openbsd-${pkgver%_*}
  for i in `cat ../debian/patches/series`; do
	echo "** patch $i" 1>&2
	cat "../debian/patches/$i"
  done | patch -p1
  patch -p1 -i "${srcdir}/openbsd-netcat.patch"
}

build() {
  cd "$srcdir"/netcat-openbsd-${pkgver%_*}
  make
}

package() {
  cd "$srcdir"/netcat-openbsd-${pkgver%_*}
  install -Dm0755 nc "$pkgdir"/usr/bin/nc
  ln -s nc "$pkgdir"/usr/bin/netcat
  install -Dm0644 nc.1 "$pkgdir"/usr/share/man/man1/nc.1
  install -dm0755 "$pkgdir"/usr/share/licenses/$pkgname/
  head -n28 netcat.c | tail -n+2 >"$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}
